package users

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCollectAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectAddLogic {
	return &CollectAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 个人收藏添加
func (l *CollectAddLogic) CollectAdd(req *types.CollectAddRequest) (resp *types.Response, err error) {
	add, err := l.svcCtx.UserRpc.CollectAdd(l.ctx, &user.CollectAddRequest{
		UserId: req.UserId,
		GoodId: req.GoodId,
		SkuId:  req.SkuId,
	})
	if err != nil {
		pkg.Error("添加失败", zap.Error(err))
		return nil, err
	}
	return respons.Success(add), nil
}
